<template>
  <el-radio-group v-bind="$attrs" v-on="$listeners" v-model="radioValue" @change="value => $emit('on-value-change', value)">
    <el-radio
      v-for="(item,index) in _options"
      :key="index"
      :label="item.value"
      v-model="item.value"
    >
      {{ item.label }}
    </el-radio>
  </el-radio-group>
</template>
<script>
export default {
  name: 'base-radio-group',
  data () {
    return {
      options: [],
      radioValue: '',
      defaultProps: {
        label: 'label',
        value: 'value'
      }
    }
  },
  model: {
    prop: 'value',
    event: 'on-value-change'
  },
  props: {
    value: {
      default: () => undefined
    }
  },
  computed: {
    _options () {
      return this.$attrs.options || this.options
    },
    defaultPropsName () {
      return this.$attrs.defaultProps || this.defaultProps
    }
  },
  watch: {
    value: {
      handler (val) {
        this.radioValue = val || '';
      },
      deep: true,
      immediate: true
    }
  },
  mounted () {
  }
};
</script>
